<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>修改密码</title>

    <link rel="stylesheet" type="text/css" href="css/aui.css">
    <link rel="stylesheet" href="css/style.css" />
	<link rel="stylesheet" href="css/my.css">
	<link rel="stylesheet" href="js/layer/need/layer.css" />
    <style>
        input.aui-input{
			border: 1px solid #ddd;
			border-radius: 5px;
			-webkit-border-radius: 5px;
			-moz-border-radius: 5px;
			padding-left: 15px;
			font-size: .6rem;
		}

    </style>
</head>

<body class="aui-background-white">
    <!--header-->
    <header class="aui-bar aui-bar-nav aui-bar-nav-search aui-text-default aui-background-white">
        <a class="aui-pull-left aui-btn " href="JavaScript:history.go(-1)">
	        <span class="aui-iconfont aui-icon-left aui-text-gray"></span>
	    </a>
        <div class="aui-title">
           	 修改密码
        </div>
    </header>

    <!--购物车已有商品列表-->
    
    <section class="aui-content aui-nav-search-fixed" style="margin-top: 2.5rem;">
       <div class="divHeight"></div>
       <div class="aui-content">
       	<div class="aui-padded-l-15 aui-padded-r-15 aui-padded-t-10">
       		<div class="aui-input-row aui-margin-b-10">
       			<input type="password" class="aui-input-clear aui-input" id="oldpwd" placeholder="请输入旧密码">
       		</div>
       		<div class="aui-input-row aui-margin-b-10">
       			<input type="password" class="aui-input-clear aui-input" id="newpwd" placeholder="请输入新密码">
       		</div>   
			<div class="aui-input-row aui-margin-b-10">
				<input type="password" class="aui-input-clear aui-input" id="qrnewpwd" placeholder="请再次输入新密码">
			</div> 	
       	</div>
       	<div class="aui-content-padded aui-btn-submit">
       		<button class="aui-btn aui-btn-block aui-btn-primary" onclick="updatePwd()">确认修改</button>
       	</div>
       
       </div>
    </section>


    <script src="js/jquery-1.7.2.min.js"></script>
	<script src="js/islogin.js"></script>
	<script src="js/layer/layer.js"></script>
    <script>
		var baseurl = 'http://kt.zhangzhengjiang.top/api/';
		function updatePwd(){
			var oldpwd = $('#oldpwd').val();
			var newpwd = $('#newpwd').val();
			var qrnewpwd = $('#qrnewpwd').val();
			var uid = window.localStorage.getItem('uid');
			if (oldpwd&&newpwd&&qrnewpwd) {
				if(newpwd == qrnewpwd){
					$.ajax({
						url:baseurl+'index/setPwd',
						type:'post',
						data:{oldpwd:oldpwd,uid:uid,newpwd:newpwd},
						success:function(res){
							if(res.code == 1){
							  layer.open({
								content: res.msg
								,skin: 'msg'
								,time: 2   
							  });
							  setTimeout(function(){
								    window.location.href='./my.html';
							  },2000);
							}else{
								layer.open({
									content: res.msg
									,skin: 'msg'
									,time: 2 ,//2秒后自动关闭
									
								});
							}
						}
					})
				}else{
					layer.open({
						content: '输入的两次新密码不一致'
						,skin: 'msg'
						,time: 2 ,//2秒后自动关闭
						
					});
				}
				
			}else{
				layer.open({
					content: '请完善信息后提交'
					,skin: 'msg'
					,time: 2 ,//2秒后自动关闭
					
				});
			}
		}

    </script>

</body>

</html>
